/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package co.umb.MAS.WebService;

import co.umb.MAS.Models.DAOs.FactoryDao;
import co.umb.MAS.Models.DAOs.PostgresPersonaDao;
import co.umb.MAS.Models.PersonaModel;
import java.util.ArrayList;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
 *
 * @author Alexander
 */
@WebService(serviceName = "PaicientesMASWebService")
public class PaicientesMASWebService {

    /**
     * This is a sample web service operation
     */
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        return "Hello " + txt + " !";
    }

    /**
     * Web service operation
     */
    @WebMethod(operationName = "postgresPacienteMAS")
    public String ObtenerPacienteMAS(@WebParam(name = "cedulaPaciente") String cedulaPaciente) {
        //TODO write your implementation code here:
        FactoryDao f = FactoryDao.getFactoryDao(FactoryDao.POSTGRES_FACTORY_DAO);        
        PostgresPersonaDao p = (PostgresPersonaDao) f.getPersonaDao();
        return p.consultarPorCedula(cedulaPaciente);
    }

    /**
     * Web service operation
     */
    @WebMethod(operationName = "postgresPacienteTodos")
    public String postgresPacienteTodos() {
        String pacientes="";
        FactoryDao fc = FactoryDao.getFactoryDao(FactoryDao.POSTGRES_FACTORY_DAO);
        ArrayList<PersonaModel> arra = fc.getPersonaDao().consultarTodos();
        for (PersonaModel persona : arra) {
            pacientes += persona.toString() + "/n";
        }       
        return pacientes;
    }
}
